home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
026-050
/
scopedisk33
/
rxenv
/
rxmake.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-03-18
|
5KB
|
251 lines
/* Simple MAKE routine written in ARexx */
address COMMAND
drop Src. Obj.
'set dateformat=-0'
'list Source:*.c to ram:$$source'
'list Obj:*.o to ram:$$obj'
call open( 'source', 'ram:$$source', 'R' )
call open( 'obj', 'ram:$$obj', 'R' )
call open( 'comp', 'ram:$$comp', 'W' )
arg compile_all
call readln( 'source' )
call getdateparms
parmresult = 1
do forever
if eof( 'source' ) then break
instring = readln( 'source' )
call getparm
if parmresult = 0 then iterate
Src. = fname
Src.sd = date
Src.st = time
if ( compile_all ~== 'ALL' )
then do
gomf = 0
call seek( 'obj', 0, 'B' )
do forever
if eof( 'obj' ) then gomf = 1
if gomf then break
instring = readln( 'obj' )
call getparm
if ( compare( Src., fname ) = 0) then break
end
if gomf
then call makecomp
else do
Obj. = fname
Obj.od = date
Obj.ot = time
call chkday( compare( Src.sd, Obj.od ) )
end
end
else call makecomp
end
call close( 'source' )
call close( 'obj' )
call writeln( 'comp', 'rxlink Main' )
call close( 'comp' )
'delete ram:$$source'
'delete ram:$$obj'
'delete ram:$$date'
echo ''
echo 'Type...'
echo ''
echo ' execute ram:$$comp'
echo ''
echo ' ...to begin the compile and link process.'
exit
getparm:
temp = pos( '.', instring ) - 1
if temp = -1
then parmresult = 0
else do
parmresult = 1
fname = left( instring, temp )
date = subword( instring, 4, 1 )
time = subword( instring, 5, 1 )
end
return(1)
a2d:
arg string
tens = (c2d( substr(string,1,1) ) - 48) * 10
digits = (c2d( substr(string,2,1) ) - 48)
d = tens + digits
return( d )
d2a:
arg d
tens = d % 10 + 48
digits = d // 10 + 48
string = d2c(tens) || d2c(digits)
return(string)
chkday:
arg diff
if diff = 0
then call chkhrs
else call comparedates( Src.sd, Obj.od )
return(1)
chkhrs:
hours = a2d( substr(Src.st,1,2) ) - a2d( substr(Obj.ot,1,2) )
diffmin = a2d( substr(Src.st,4,2) ) - a2d( substr(Obj.ot,4,2) )
diffsec = a2d( substr(Src.st,7,2) ) - a2d( substr(Obj.ot,7,2) )
select
when hours < 0 then echo Src. 'will NOT be compiled...'
when hours > 0 then call makecomp
otherwise do
if diffmin < 0
then echo Src. 'will NOT be compiled...'
else if diffsec < 0
then echo Src. 'will NOT be compiled...'
else call makecomp
end
end
return(1)
getdateparms:
dayname.1 = 'Sunday'
dayname.2 = 'Monday'
dayname.3 = 'Tuesday'
dayname.4 = 'Wednesday'
dayname.5 = 'Thursday'
dayname.6 = 'Friday'
dayname.7 = 'Saturday'
'date >ram:$$date'
call open( 'datefile','ram:$$date','R' )
instring = readln( 'datefile' )
call close( 'datefile' )
day = subword( instring, 1, 1 )
date = subword( instring, 2, 1 )
todaysnum = dayofweek( day )
dayname.todaysnum.fullnum = date
todaysdate = a2d( date,1,2 )
call setdaydate
return(1)
setdaydate:
arg weekday
x = todaysnum
do i = 1 to 6
if x = 1
then x = 7
else x = x - 1
y = todaysdate - i
dayname.x.fullnum = d2a(y) || right(date, 7)
end
return(1)
dayofweek:
arg weekday
select
when weekday = 'SUNDAY' then datenumber = 1
when weekday = 'MONDAY' then datenumber = 2
when weekday = 'TUESDAY' then datenumber = 3
when weekday = 'WEDNESDAY' then datenumber = 4
when weekday = 'THURSDAY' then datenumber = 5
when weekday = 'FRIDAY' then datenumber = 6
when weekday = 'SATURDAY' then datenumber = 7
when weekday = 'TODAY' then datenumber = 8
when weekday = 'YESTERDAY' then datenumber = 9
otherwise datenumber = 0
end
return(datenumber)
monthofyear:
arg num
select
when num = 'JAN' then monthnum = 1
when num = 'FEB' then monthnum = 2
when num = 'MAR' then monthnum = 3
when num = 'APR' then monthnum = 4
when num = 'MAY' then monthnum = 5
when num = 'JUN' then monthnum = 6
when num = 'JUL' then monthnum = 7
when num = 'AUG' then monthnum = 8
when num = 'SEP' then monthnum = 9
when num = 'OCT' then monthnum = 10
when num = 'NOV' then monthnum = 11
when num = 'DEC' then monthnum = 12
otherwise monthnum = 0
end
return(monthnum)
comparedates:
arg Srcdate, Objdate
snum = dayofweek(Srcdate)
if snum = 0
then sdate = Srcdate
else if snum >= 8
then do
temp = todaysnum - (snum - 8)
sdate = dayname.temp.fullnum
end
else sdate = dayname.snum.fullnum
onum = dayofweek(Objdate)
if onum = 0
then odate = Objdate
else if onum >= 8
then do
temp = todaysnum - (onum - 8)
odate = dayname.temp.fullnum
end
else odate = dayname.onum.fullnum
call chkyear( sdate, odate )
return(diff)
chkyear:
arg s, o
if compare( right(s,2), right(o,2) )
then do
temp1 = a2d(right(s,2)
temp2 = a2d(right(o,2)
end
else do
if compare( substr(s,4,3), substr(o,4,3) )
then do
temp1 = monthofyear( substr(s,4,3) )
temp2 = monthofyear( substr(o,4,3) )
end
else do
temp1 = a2d(left(s,2))
temp2 = a2d(left(o,2))
end
end
if ( (temp1 - temp2) >= 1 )
then call makecomp
else echo Src. 'will NOT be compiled...'
return(1)
makecomp:
echo Src. 'will be compiled...'
call writeln( 'comp', 'rxcomp ' || Src. )
return(1)